/**
 * Created by 李海强1 on 2016/10/12.
 */
Ext.define('UDZ.controller.Ctr_Personal_myinfo', {
    extend: 'Ext.app.Controller',
    init:function () { //初始化可以加载数据，但不可以对控制件进行操作
        // Ext.getCmp('btn_go').setText('gogogo') ;  //不可行，因为控件还没加载出来
    },
    config: {
        refs: {
            myinfoview:{
                selector:'myinfo',
                xtype:'myinfo',
                autoCreate:true
            },
            myinfo_back:'#myinfo_back', //返回个人中心
            my_sex:'#my_sex', //修改性别
            go_change_nick:'#go_change_nick',//去修改昵称
            go_change_email:'#go_change_email',//去修改邮箱
            show_image:'#my_image',//查看头像
            go_change_header:'#go_change_header', //修改头像
            myinfo_go_address:'#myinfo_go_address'//所在地区
        },
        control:{
            myinfo_back:{
                tap:'func_backPersonal'
            },
            my_sex:{
                initialize:'func_my_sex',
            },
            go_change_nick:{
                initialize:'func_go_change_nick',
            },
            go_change_email:{
                initialize:'func_go_change_email',
            },
            show_image:{
                initialize:'func_show_image_panel',
            },
            go_change_header:{
                initialize:'func_go_change_header',
            },
            myinfo_go_address:{
                initialize:'func_myinfo_go_address',
            },
        },
        routes: { //自己的路由
            'route_myinfo': 'showMyinfo',
            'route_myinfo_to': 'showMyinfoTo',
        },
    },
    showMyinfo:function (){
        Ext.Viewport.animateActiveItem(this.getMyinfoview(),{type:'slide',duration:500,direction:'left'});
    },
    showMyinfoTo:function (){
        Ext.Viewport.animateActiveItem(this.getMyinfoview(),{type:'slide',duration:500,direction:'right'});
    },
    //去修改昵称
    func_go_change_nick:function (){
        var me=this;
        Ext.getCmp('go_change_nick').element.on({
            tap:function(){
                me.redirectTo('route_change_nick');
            }
        });
    },

    //修改邮箱
    func_go_change_email:function (){
        var me=this;
        Ext.getCmp('go_change_email').element.on({
            tap:function(){
                me.redirectTo('route_change_email');
            }
        });
    },

     //修改性别
    func_my_sex:function () {
        Ext.getCmp('my_sex').element.on({
            tap:function(){
                Ext.Viewport.add({
                    xtype:'bigpanel'
                });
                Ext.getCmp('bigConfirm').setHandler(function(){
                    Ext.getCmp('my_sex').setHtml(JSON.stringify(Ext.getCmp('sex_panel').getValues().sex).split('"')[1]);
                    Ext.getCmp('bigPanel').destroy();
                });
                Ext.getCmp('bigClose').setHandler(function(){
                    Ext.getCmp('bigPanel').destroy();
                });
            }
        });
    },
    func_backPersonal:function () { //方法
        this.redirectTo('route_main');
    },
    //查看头像
    func_show_image_panel:function () {
        Ext.getCmp('my_image').element.on({
            tap : function() {
                var a = Ext.Viewport.add({
                    xtype: 'panel',
                    height:'100%',
                    cls:'show_image_panel',
                    style:'background-color:rgba(0,0,0,0.8);margin-top:-22%',
                    items:[
                        {
                            xtype: 'image',
                            id:'show_image',
                            style:'height:250px;top:230px',
                            margin: '0 auto',
                            listeners: {
                                tap:function(){
                                    Ext.getCmp('index').setMasked();
                                }
                            }
                        }
                    ]
                });
                Ext.getCmp('index').setMasked(a);
                Ext.getCmp('show_image').setSrc(Ext.getCmp('my_image').getSrc());
            }
        });
    },
    //修改头像
    func_go_change_header:function (){
        var me=this;
        Ext.getCmp('go_change_header').element.on({
            tap:function(){
                me.redirectTo('route_change_header');
            }
        });
    },
    //所在地区
    func_myinfo_go_address:function (){
        var me=this;
        Ext.getCmp('myinfo_go_address').element.on({
            tap:function(){
                me.redirectTo('route_address_manger');
            }
        });
    },
});